

import React, { useEffect, useState } from "react"
import { ParkApi } from '../api/api'
import { Image } from "antd-mobile"
import { useParams } from "react-router-dom"

export default function ParkDetails() {
   const [list, setlist] = useState<any>([])
   console.log(list);

   const { id }: any = useParams()

   const park = async () => {
      let res = await ParkApi(id)
      setlist(res.data.data)
   }

   useEffect(() => {
      park()
   }, [])

   if (list) {
      return (
         <div>
            <h2>
               {list.address}
            </h2>
            <div>
               <Image src={'http://124.93.196.45:10001/' + list.imgUrl} ></Image>
            </div>
            <div>
               空位个数:{list.vacancy}
            </div>
            <div>
               收费:{list.rates}
            </div>
            <div>
               停车场名称:{list.parkName}
            </div>
            <div>
               距离（米）:{list.distance}
            </div>
            <div>
               总停车位:{list.allPark}
            </div>
         </div>
      )
   } else {
      return (
         <div></div>
      )
   }

}

